/**
 *  A Truveo Video Search AS3 API port of version 3
 * 	Author: Juan Sebastian Cadena
 *  Date: 21/0/08
 *  mail: sebastiancadena@gmail.com
 */
package com.meetEarth.actionScript
{
	import flash.xml.XMLDocument;
	
	
	 /////////////////////////////////////////////////////////////////////////////////////////
	// The TruveoVideoSearch class is the top-level class for the Truveo Video Search Flash API. 
	/////////////////////////////////////////////////////////////////////////////////////////
	
	public class TruveoVideoSearch
	{
		
		///// Member variables with get and/or set privileges
		// Request attributes
		private var appID:String;					// application ID
		private var results:Number = 10;			// number of results to be returned
		private var tagResults:Number = 10;		// number of related tags to be returned
		private var channelResults:Number = 10;  	// number of related channels to be returned
		private var categoryResults:Number = 10;  	// number of related categories to be returned
		private var userResults:Number = 10;  		// number of related users to be returned
		private var showRelatedItems:Number = 0;  	// flag that indicates if related tags, channels, categories and users should be returned
		private var showAdult:Number = 0;  		// flag that indicates if adult content should be included in result set
		private var start:Number = 0;				// starting position of the first result
		
		// Response attributes
		private var method:String;   			// string containing the name of the API method
		private var query:String;    			// string containing the query that was submitted
		private var querySuggestion:String;  	// string containing a suggested query (if available)
		private var videoSet:Object = null;
		private var tagSet:Object = null;
		private var categorySet:Object = null;
		private var channelSet:Object = null;
		private var userSet:Object = null;
		private var Result:Object = null;
	
		///// Private member variables
		private var xmlDoc:XML;   	// XML document representing the response
		
		
		// Error messages
		private var errorMessages:Object = {code_502: "Invalid Flash method call: The wrong number of arguments was provided to this method.",
											 code_503: "Method not available: You must be logged in to use this method.",
											 code_400: "Bad API request or API Service unavailable. Check that the parameters to the request are correctly specified."};
		// Constructor for TruveoVideoSearch object.
		// Parameters:
		//		appID (required): application ID against which all queries will be executed
		public function TruveoVideoSearch(appID:String) {
			this.appID = appID;
		}
		// Implements API method: truveo.videos.getVideos
		// Parameters: 
		//		query (optional; defaults to ""): the query to execute.  This should follow the format specified in http://developer.truveo.com/SearchQueryOverview.php
		//		start (optional; defaults to 0): the starting position of the first result
		// Events:
		//		onupdate:  This event will be dispatched when the XML results have been received, the XML has been successfully parsed, and the VideoSet
		//					object has been populated.
		//		onerror:   This event will be dispatched when the XML results include an Error.
		// Return value:
		//		'true' if the XML API request was sent successfully.
		public function getVideos(query:String, start:Number):Boolean {
			if (this.query == null) this.query="";  // default to empty query
			if (this.start == null) this.start=0;   // default to start position of 0
		}
	}
}